home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QRZ! Ham Radio 6
/
QRZ Ham Radio Callsign Database - Volume 6.iso
/
mac
/
files
/
amiga
/
csrc720j.lzh
/
seek.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-10
|
1KB
|
65 lines
/* seek.c */
#include <stdio.h>
#include <time.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
/* DO NOT include amiga.h in here ... it redefines fseek and lseek
and would make the myfseek and mylseek routines infinitely recursive
which is not quite what is wanted
#include "amiga.h"
*/
/* Two workarounds for the fseek and lseek functions which do not
seek past the end of file
amiga.h contains macro redefinitions of lseek and fseek
*/
myfseek(str,offs,org)
FILE *str;
long offs;
int org;
{
char astr[128];
int ret;
long k;
if(fseek(str,offs,org) == -1) {
k = fseek(str,0L,2);
k = offs - k;
while(k > 0){
if(k >= 128) {
fwrite(astr,128,1,str);
k -= 128;
}
else {
fwrite(astr,k,1,str);
k = 0;
}
}
}
}
mylseek(fid,offs,org)
int fid;
long offs;
int org;
{
char astr[128];
long k,j;
if(lseek(fid,offs,org) == -1L) {
k = lseek(fid,0L,2);
k = offs - k;
while(k > 0){
if(k >= 128) {
write(fid,astr,128);
k -= 128;
}
else {
write(fid,astr,k);
k = 0;
}
}
}
return(offs);
}